<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>layui</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" href="/static/admin/lib/layui-v2.6.3/css/layui.css" media="all">
  <link rel="stylesheet" href="/static/admin/lib/font-awesome-4.7.0/css/font-awesome.min.css" media="all">
  <link rel="stylesheet" href="/static/admin/css/public.css" media="all">
</head>
<body>
<div class="layuimini-container">
  <div class="layuimini-main">
    <form class="layui-form">
      <div class="layui-form-item">

        <div class="layui-form-item">
          <div class="layui-inline">
            <label class="layui-form-label">菜单名称</label>
            <div class="layui-input-inline">
              <input type="text" name="menu_name" lay-verify="required" autocomplete="off" class="layui-input" value="{$info.menu_name}">
            </div>
          </div>
          <div class="layui-inline">
            <label class="layui-form-label">所属菜单</label>
            <div class="layui-input-inline">
              <select name="pid" lay-verify="required" lay-search="">
                <option value="0" {if $info.pid == 0}selected{/if} >顶级菜单</option>
                {volist name="$menus" id="ms"}
                  <option value="{$ms.menu_id}" {if $info.pid == $ms.menu_id}selected{/if} >{$ms.menu_name}</option>
                {/volist}
              </select>
            </div>
          </div>
        </div>

        <div class="layui-form-item">
          <div class="layui-inline">
            <label class="layui-form-label">菜单路径</label>
            <div class="layui-input-inline">
              <input type="text" name="menu_path" autocomplete="off" class="layui-input" placeholder="/module/controller/action" value="{$info.menu_path}">
            </div>
          </div>
          <div class="layui-inline">
            <label for="" class="layui-form-label">菜单图标</label>
            <div class="layui-input-block">
              <input type="text" name="menu_icon"  class="layui-input" value="{$info.menu_icon}">
            </div>
          </div>
        </div>


        <div class="layui-form-item">
          <div class="layui-inline">
            <label class="layui-form-label">菜单类型</label>
            <div class="layui-input-inline">
                <select name="menu_type">
                  <option value="1" {if $info.menu_type == 1}selected{/if} >目录</option>
                  <option value="2" {if $info.menu_type == 2}selected{/if} >菜单</option>
                  <option value="3" {if $info.menu_type == 3}selected{/if} >按钮</option>
                </select>
            </div>
          </div>
          <div class="layui-inline">
            <label class="layui-form-label">菜单排序</label>
            <div class="layui-input-block">
              <input type="number" name="menu_sort"  value="{$info.menu_sort}" class="layui-input">
            </div>
          </div>
        </div>
        <input type="hidden" name="menu_id" value="{$info.menu_id}">
      <div class="layui-form-item">
        <div class="layui-input-block">
          <button class="layui-btn" type="button" lay-submit="" lay-filter="zz_add">立即提交</button>
          <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
      </div>
    </form>
  </div>
</div>

<script src="/static/admin/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script src="/static/admin/js/lay-config.js?v=1.0.4" charset="utf-8"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
  layui.use(['form','iconPickerFa'], function () {
    var form = layui.form
            , layer = layui.layer
            , $ = layui.$;


    //监听提交
    form.on('submit(zz_add)', function (data) {
      data = data.field;
      $.ajax({
          url : '/back/menu/edit',
          data :data,
          type:'POST',
          success:function(res){
            if(res.code == 1){
              layer.msg(res.msg,{icon:1,time:2000},function(){
                var index = parent.layer.getFrameIndex(window.name);
                parent.location.reload();
                parent.layer.close(index);
              });
            }else{}
              layer.msg(res.msg,{icon:1});
          }
      });
      return false;
    });



  });
</script>

</body>
</html>